package com.fowo.api.pda.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.common.model.R;
import com.fowo.api.model.receipt.ReceiptSearchParamPo;
import com.fowo.api.model.receipt.ReceiptVo;
import com.fowo.api.pda.service.PdaReceiptService;
import com.fowo.api.service.ReceiptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Tag(name = "PDA收货管理")
@RequestMapping("/api/pda/receipt")
@RestController
public class PdaReceiptController {
    @Resource
    private ReceiptService receiptService;
    @Resource
    private PdaReceiptService pdaReceiptService;

    @Operation(summary = "单据列表")
    @GetMapping
    public R<Page<?>> search(ReceiptSearchParamPo search) {
//        search.setStatusEq("0");
        return R.data(receiptService.waitForReceivingPageWithChildSearch(search));
    }

    @Operation(summary = "获取详情")
    @GetMapping("{id}")
    public R<ReceiptVo> getVoById(@PathVariable Long id) {
        return R.data(() -> receiptService.getVoById(id));
    }

    @Operation(summary = "确认收货")
    @PutMapping("receiptReceiptButton")
    public R<?> receiptReceiptButton(@RequestBody ReceiptVo model) throws Exception {
        return R.run(() -> pdaReceiptService.receiptReceipt(model));
    }

}
